package zhishuang.wang.sansi.x9.plantask;

/**
 * @Author Zhishuang.Wang
 * @Date 2023/7/5 11:24
 * @Email 1406110602@qq.com
 */

import zhishuang.wang.sansi.tools.ReturnData;
import zhishuang.wang.sansi.tools.time.DateFormat;

public class PlanItemInfor {
    private String itemId;
    private Integer monthFlag;
    private Integer weekFlag;
    private Integer dayFlag;
    private int execType = 0;
    private int execTime;
    private int ctrlType;
    private int ctrlValue;

    public PlanItemInfor() {
    }

    public ReturnData checkParam() {
        ReturnData rd = new ReturnData();
        String errMessage = "";
        if (this.itemId == null || this.itemId.length() == 0) {
            errMessage = errMessage + "计划项ID必填\n";
        }

        if (this.execTime < 0 || this.execTime > 86400) {
            errMessage = errMessage + "执行时间点取值范围：0 - 86400\n";
        }

        if (this.ctrlType < 0 || this.ctrlType > 1) {
            errMessage = errMessage + "控制类型取值范围：0 - 1\n";
        }

        if (this.ctrlType == 0) {
            if (this.ctrlValue < 0 || this.ctrlValue > 1) {
                errMessage = errMessage + "控制值(控制电源开关)取值范围：0 - 1\n";
            }
        } else if (this.ctrlValue < 0 || this.ctrlValue > 100) {
            errMessage = errMessage + "控制值(控制亮度)取值范围：0 - 100\n";
        }

        if (this.monthFlag == null) {
            this.monthFlag = 2047;
        }

        if (this.weekFlag == null) {
            this.weekFlag = 127;
        }

        if (this.dayFlag == null) {
            this.dayFlag = Integer.MAX_VALUE;
        }

        if (errMessage.length() > 1) {
            rd.setMessage(errMessage);
        } else {
            rd.setCode(0);
        }

        rd.setTime(DateFormat.getNowDataFormat());
        return rd;
    }

    public String getItemId() {
        return this.itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public Integer getMonthFlag() {
        return this.monthFlag;
    }

    public void setMonthFlag(Integer monthFlag) {
        this.monthFlag = monthFlag;
    }

    public Integer getWeekFlag() {
        return this.weekFlag;
    }

    public void setWeekFlag(Integer weekFlag) {
        this.weekFlag = weekFlag;
    }

    public Integer getDayFlag() {
        return this.dayFlag;
    }

    public void setDayFlag(Integer dayFlag) {
        this.dayFlag = dayFlag;
    }

    public int getExecTime() {
        return this.execTime;
    }

    public void setExecTime(int execTime) {
        this.execTime = execTime;
    }

    public int getCtrlType() {
        return this.ctrlType;
    }

    public void setCtrlType(int ctrlType) {
        this.ctrlType = ctrlType;
    }

    public int getCtrlValue() {
        return this.ctrlValue;
    }

    public void setCtrlValue(int ctrlValue) {
        this.ctrlValue = ctrlValue;
    }
}
